package RentCar;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class RentMgrSys {
    private List<Car> carList = new ArrayList<>();
    private List<Bus> busList = new ArrayList<>();
    private List<Trunk> trunkList = new ArrayList<>();

    public RentMgrSys() {
        Car car1 = new Car("京NY28588", "宝马", "-X6", 800);
        Car car2 = new Car("京CNY3284", "宝马", "-550i", 600);
        Car car3 = new Car("京NT37465", "别克", "林荫大道", 300);
        Car car4 = new Car("京NT96968", "别克", "GL8", 600);
        carList.add(car1);
        carList.add(car2);
        carList.add(car3);
        carList.add(car4);

        Bus bus1 = new Bus("京6566754", "金杯", "16座", 800);
        Bus bus2 = new Bus("京8696997", "金杯", "16座", 800);
        Bus bus3 = new Bus("京9696996", "金龙", "34座", 1500);
        Bus bus4 = new Bus("京8696998", "金龙", "34座", 1500);
        busList.add(bus1);
        busList.add(bus2);
        busList.add(bus3);
        busList.add(bus4);

        Trunk trunk1 = new Trunk("京NB11111", "一汽", "10", 2000);
        Trunk trunk2 = new Trunk("京VB22222", "一汽", "20", 2500);
        Trunk trunk3 = new Trunk("京NM33333", "雷诺", "10", 3000);
        Trunk trunk4 = new Trunk("京KL44444", "雷诺", "20", 3500);
        trunkList.add(trunk1);
        trunkList.add(trunk2);
        trunkList.add(trunk3);
        trunkList.add(trunk4);
    }

    //租车流程
    public void leaseOutFlow() {
        Scanner scanner = new Scanner(System.in);

        //通过choice来进行后面的租金计算和车牌选择
        System.out.println("********** 欢迎光临腾飞汽车租赁公司 **********");
        System.out.println("1. 轿车   2. 客车   3. 卡车");
        System.out.print("请选择你要租赁的汽车类型 :");
        int x = scanner.nextInt();
        if (x == 1) {
            carLeaseOut();
        } else if (x == 2) {
            busLeaseOut();
        } else if (x == 3) {
            trunkLeaseOut();
        } else {
            System.out.println("输入错误!!!");
        }

    }

    public void carLeaseOut() {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 宝马     2. 别克");
        System.out.print("请选择你要租赁的轿车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. X6    2. 550i");
        } else if (brand == 2) {
            System.out.println("1. 林荫大道 2. GL8");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请选择你要租赁的轿车型号: ");
        int type = scanner.nextInt();
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + carList.get(choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + carList.get(choice - 1).calRent(days) + "元");
    }

    public void busLeaseOut() {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 金杯     2. 金龙");
        System.out.print("请选择你要租赁的客车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. 金杯一    2. 金杯二");
        } else if (brand == 2) {
            System.out.println("1. 金龙一 2. 金龙二");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请选择你要租赁哪个车: ");
        int type = scanner.nextInt();
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + busList.get(choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + busList.get(choice - 1).calRent(days) + "元");
    }

    public void trunkLeaseOut() {
        Scanner scanner = new Scanner(System.in);
        int choice;
        System.out.println("1. 一汽     2. 雷诺");
        System.out.print("请选择你要租赁的卡车品牌: ");
        int brand = scanner.nextInt();
        choice = brand;
        if (brand == 1) {
            System.out.println("1. 一汽一(10t)    2. 一汽二(20t)");
        } else if (brand == 2) {
            System.out.println("1. 雷诺一(10t) 2. 雷诺二(20t)");
        } else {
            System.out.println("输入错误!!!");
        }
        System.out.print("请输入你需求的卡车承载量(t): ");
        int t = scanner.nextInt();
        int type = t / 10;
        if (brand == 1) {
            choice += type - 1;
        } else if (brand == 2) {
            choice += type;
        }
        System.out.print("请选择你要租赁的天数: ");
        int days = scanner.nextInt();

        System.out.println("分配给您的汽车牌号是 :" + trunkList.get(choice - 1).getVehicleId());
        System.out.println("您需要支付的租赁费用是 : " + trunkList.get(choice - 1).calRent(days) + "元");
    }
}
